<!doctype html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />



  <meta name="google-site-verification" content="TrUnMASAEpWPLf28sUVl5VSxwgl4myBCO_6PiHidBaU" />













  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.lug.ustc.edu.cn//css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






  

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.2/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="李三来,lisanlai,给太阳洒水" />





  <link rel="alternate" href="/atom.xml" title="Sam's Blog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="Success is the sum of small efforts, repeated day in and day out.">
<meta property="og:type" content="website">
<meta property="og:title" content="Sam&#39;s Blog">
<meta property="og:url" content="http://blog.lisanlai.cn/index.html">
<meta property="og:site_name" content="Sam&#39;s Blog">
<meta property="og:description" content="Success is the sum of small efforts, repeated day in and day out.">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Sam&#39;s Blog">
<meta name="twitter:description" content="Success is the sum of small efforts, repeated day in and day out.">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '6275635457204159000',
      author: 'Author'
    },
    algolia: {
      applicationID: 'KWML0K50GI',
      apiKey: 'd54291e92bb62d32f0fbc5f0b6732a22',
      indexName: 'Index_blog_lisanlai_cn',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://blog.lisanlai.cn/"/>





  <title> Sam's Blog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  














  
  
    
  

  <div class="container sidebar-position-left 
   page-home 
 ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Sam's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description"></h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  
  <div class="algolia-popup popup search-popup">
    <div class="algolia-search">
      <div class="algolia-search-input-icon">
        <i class="fa fa-search"></i>
      </div>
      <div class="algolia-search-input" id="algolia-search-input"></div>
    </div>

    <div class="algolia-results">
      <div id="algolia-stats"></div>
      <div id="algolia-hits"></div>
      <div id="algolia-pagination" class="algolia-pagination"></div>
    </div>

    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
  </div>




    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.lisanlai.cn/2017/04/01/Spring-Cloud-系列教程(2-1) -Eureka-服务注册中心/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李三来">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sam's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/04/01/Spring-Cloud-系列教程(2-1) -Eureka-服务注册中心/" itemprop="url">
                  Spring Cloud系列教程(2.1) - Eureka(服务注册中心)
                </a>
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-04-01T17:49:36+08:00">
                2017-04-01
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Spring-Cloud/" itemprop="url" rel="index">
                    <span itemprop="name">Spring Cloud</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/04/01/Spring-Cloud-系列教程(2-1) -Eureka-服务注册中心/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/04/01/Spring-Cloud-系列教程(2-1) -Eureka-服务注册中心/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h2 id="1-什么是服务？"><a href="#1-什么是服务？" class="headerlink" title="1. 什么是服务？"></a>1. 什么是服务？</h2><p>在软件开发领域，到处可见<strong>服务</strong>一词，而我们这里说的<strong>服务</strong>，我个人觉得与“<strong>微服务</strong>”这个词是分不开。微服务架构近两年兴起，Spring Cloud正是微服务架构的一套解决方案或者框架。</p>
<p><strong>那什么是微服务呢？</strong></p>
<p>官方定义如下：</p>
<div class="note success"><p>The microservice architectural style is an approach to developing a single application as <strong>a suite of small services</strong>, each <strong>running in its own process</strong> and communicating with lightweight mechanisms, often an HTTP resource API. These services are <strong>built around business capabilities</strong> and independently deployable by fully automated deployment machinery. There is <strong>a bare minimum of centralized management of these services</strong> , which may be written in different programming languages and use different data storage technologies.<br>– James Lewis and Martin Fowler</p>
<p>想更多了解，可以阅读Martin Fowler的<a href="http://martinfowler.com/articles/microservices.html" target="_blank" rel="noopener">《Microservices》</a>.</p>
</div>
<p><strong>简单的说，微服务架构就是将一个完整的应用从数据存储开始垂直拆分成多个不同的服务，每个服务都能独立部署、独立维护、独立扩展，服务与服务间通过诸如RESTful API或者RPC等方式互相调用。</strong></p>
<h2 id="2-Service-Registry-服务注册与发现"><a href="#2-Service-Registry-服务注册与发现" class="headerlink" title="2. Service Registry(服务注册与发现)"></a>2. Service Registry(服务注册与发现)</h2><p>在了解什么是服务之后，下面我们来看看要如何使用Spring Cloud去实现服务的注册和发现。</p>
<p>要实现服务的注册的发现，Spring Cloud提供的不止一套方案，其中<a href="http://cloud.spring.io/spring-cloud-static/Camden.SR6/#_spring_cloud_zookeeper" target="_blank" rel="noopener">Spring Cloud Zookeeper</a>, <a href="http://cloud.spring.io/spring-cloud-static/Camden.SR6/#_spring_cloud_consul" target="_blank" rel="noopener">Spring Cloud Consul</a> 和 <a href="http://cloud.spring.io/spring-cloud-static/Camden.SR6/#_service_discovery_eureka_clients" target="_blank" rel="noopener">Spring Cloud Eureka</a>都可以实现，而这里我们要用Eureka去实现。 </p>
<p>接下来，让我们动手写一些代码做一下尝试：</p>
<h3 id="2-1-Service-Registry-服务注册中心"><a href="#2-1-Service-Registry-服务注册中心" class="headerlink" title="2.1 Service Registry ( 服务注册中心 )"></a>2.1 Service Registry ( 服务注册中心 )</h3><p>怎么去实现一个服务注册中心，只需要使用<code>spring-cloud-starter-eureka-server</code>便可轻松完成。</p>
<p>首先，创建一个基础的Spring Boot工程，并在<code>pom.xml</code>中引入需要的依赖内容：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">parent</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-parent<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.5.2.RELEASE<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">relativePath</span>/&gt;</span> <span class="comment">&lt;!-- lookup parent from repository --&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">parent</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">properties</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">project.build.sourceEncoding</span>&gt;</span>UTF-8<span class="tag">&lt;/<span class="name">project.build.sourceEncoding</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">project.reporting.outputEncoding</span>&gt;</span>UTF-8<span class="tag">&lt;/<span class="name">project.reporting.outputEncoding</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">java.version</span>&gt;</span>1.8<span class="tag">&lt;/<span class="name">java.version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">properties</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">dependencies</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.cloud<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-cloud-starter-eureka-server<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"></span><br><span class="line">  <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-test<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">scope</span>&gt;</span>test<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependencies</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">dependencyManagement</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">dependencies</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.cloud<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-cloud-dependencies<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">version</span>&gt;</span>Camden.SR6<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">type</span>&gt;</span>pom<span class="tag">&lt;/<span class="name">type</span>&gt;</span></span><br><span class="line">      <span class="tag">&lt;<span class="name">scope</span>&gt;</span>import<span class="tag">&lt;/<span class="name">scope</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">dependencies</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependencyManagement</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>然后，使用<code>@EnableEurekaServer</code>注解来启动一个服务注册中心：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@SpringBootApplication</span></span><br><span class="line"><span class="meta">@EnableEurekaServer</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">EurekaServerApplication</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">	<span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">		<span class="keyword">new</span> SpringApplicationBuilder(EurekaServerApplication.class).web(<span class="keyword">true</span>).run(args);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>在默认配置下，服务注册中心有个自注册的行为，也就是说它会默认把自己当成客户端注册给自己，而在单实例运行情况下，我们不需要这样的自注册行为，所以我们可以通过配置关闭这种行为：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">server:</span></span><br><span class="line"><span class="attr">  port:</span> <span class="number">8761</span></span><br><span class="line"></span><br><span class="line"><span class="attr">eureka:</span></span><br><span class="line"><span class="attr">  instance:</span></span><br><span class="line"><span class="attr">    hostname:</span> <span class="string">localhost</span></span><br><span class="line"><span class="attr">  client:</span></span><br><span class="line">  	<span class="comment">#是否将eureka自身作为应用注册到eureka注册中心</span></span><br><span class="line"><span class="attr">    registerWithEureka:</span> <span class="literal">false</span> </span><br><span class="line">    <span class="comment">#启动时是否去fetch其他的注册中心</span></span><br><span class="line">    <span class="comment">#为true时，可以启动，但报异常：Cannot execute request on any known server</span></span><br><span class="line"><span class="attr">    fetchRegistry:</span> <span class="literal">false</span> </span><br><span class="line"><span class="attr">    serviceUrl:</span></span><br><span class="line"><span class="attr">      defaultZone:</span> <span class="attr">http://$&#123;eureka.instance.hostname&#125;:$&#123;server.port&#125;/eureka/</span></span><br></pre></td></tr></table></figure>
<p>服务注册中心是自带UI界面的，默认情况下，使用8761端口。如上所示，我们同样可以更改配置文件来修改服务器端口，例如：1234，1111，等等。</p>
<p>这样，我们就可以启动我们的应用，启动完成后，我们可以访问：<a href="http://localhost:8761" target="_blank" rel="noopener">http://localhost:8761</a></p>
<p>可以看到下面的页面，不过现在还没有任何服务注册进来：</p>
<img src="/2017/04/01/Spring-Cloud-系列教程(2-1)%20-Eureka-服务注册中心/registry-ui.png" title="服务注册中心">
<p>示例代码： <a href="https://github.com/lisanlai/spring-cloud/tree/master/eureka-server" target="_blank" rel="noopener">Github : eureka-server</a></p>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2017/04/01/Spring-Cloud-系列教程(2-1) -Eureka-服务注册中心/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.lisanlai.cn/2017/04/01/Spring-Cloud-系列教程(2) - Spring-Cloud-Netflix/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李三来">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sam's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/04/01/Spring-Cloud-系列教程(2) - Spring-Cloud-Netflix/" itemprop="url">
                  Spring Cloud系列教程(2)- Spring Cloud Netflix
                </a>
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-04-01T16:57:42+08:00">
                2017-04-01
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Spring-Cloud/" itemprop="url" rel="index">
                    <span itemprop="name">Spring Cloud</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/04/01/Spring-Cloud-系列教程(2) - Spring-Cloud-Netflix/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/04/01/Spring-Cloud-系列教程(2) - Spring-Cloud-Netflix/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <div class="note success"><p>This project provides Netflix OSS integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms. With a few simple annotations you can quickly enable and configure the common patterns inside your application and build large distributed systems with battle-tested Netflix components. The patterns provided include Service Discovery (Eureka), Circuit Breaker (Hystrix), Intelligent Routing (Zuul) and Client Side Load Balancing (Ribbon).</p>
</div>
<p><a href="https://cloud.spring.io/spring-cloud-netflix/" target="_blank" rel="noopener">Spring Cloud Netflix</a> 是Spring Cloud众多子项目其中之一，它主要是对Nexflix旗下一些列开源产品做了一些封装，以便于能够更好的和Spring Boot集成，例如自动配置，编程模型的绑定等等。如此一来，开发者就可以很快速的使用一些简单的注解让自己的应用自动配置一下常用的模块，进而构建庞大的分布式系统。<a href="https://cloud.spring.io/spring-cloud-netflix/" target="_blank" rel="noopener">Spring Cloud Netflix</a> 其实也是一些列组件的集合，它包含的模块有：</p>
<ul>
<li><a href="http://cloud.spring.io/spring-cloud-static/Camden.SR6/#_service_discovery_eureka_clients" target="_blank" rel="noopener">Eureka</a> - 服务注册和发现</li>
<li><a href="http://cloud.spring.io/spring-cloud-static/Camden.SR6/#_circuit_breaker_hystrix_clients" target="_blank" rel="noopener">Hystrix</a> - 熔断器</li>
<li><a href="http://cloud.spring.io/spring-cloud-static/Camden.SR6/#_router_and_filter_zuul" target="_blank" rel="noopener">Zuul</a> - 智能路由</li>
<li><a href="http://cloud.spring.io/spring-cloud-static/Camden.SR6/#spring-cloud-ribbon" target="_blank" rel="noopener">Ribbon</a> - 客户端负载均衡</li>
</ul>
<p>接下来，我们通过简单的例子一步一步的去认识这些组件：</p>
<ul>
<li><a href="http://mirror.lisanlai.cn/2017/04/01/Spring-Cloud-%E7%B3%BB%E5%88%97%E6%95%99%E7%A8%8B(2-1" target="_blank" rel="noopener">Spring-Cloud-系列教程（2.1）- Eureka ( 服务注册中心 )</a>%20-Eureka-%E6%9C%8D%E5%8A%A1%E6%B3%A8%E5%86%8C%E4%B8%AD%E5%BF%83/)</li>
<li>Spring-Cloud-系列教程（2.2）- Service Provider ( 服务注册)</li>
<li>Spring-Cloud-系列教程（2.3）- Service Consumer ( 服务消费 )</li>
<li>Spring-Cloud-系列教程（2.4）- Ribbon ( 客户端负载均衡 )</li>
<li>Spring-Cloud-系列教程（2.5）- Feign ( 客户端负载均衡 )</li>
<li>Spring-Cloud-系列教程（2.6）- Hystrix ( 熔断器 )</li>
<li>Spring-Cloud-系列教程（2.7）- Zuul ( 智能路由 )</li>
</ul>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.lisanlai.cn/2017/03/29/Spring-Cloud-系列教程(1) - 简介/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李三来">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sam's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/03/29/Spring-Cloud-系列教程(1) - 简介/" itemprop="url">
                  Spring Cloud系列教程(1) - 简介
                </a>
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-29T16:57:42+08:00">
                2017-03-29
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Spring-Cloud/" itemprop="url" rel="index">
                    <span itemprop="name">Spring Cloud</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/03/29/Spring-Cloud-系列教程(1) - 简介/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/03/29/Spring-Cloud-系列教程(1) - 简介/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="Spring-Cloud-简介"><a href="#Spring-Cloud-简介" class="headerlink" title="Spring Cloud 简介"></a>Spring Cloud 简介</h2><div class="note success"><p>Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, control bus, one-time tokens, global locks, leadership election, distributed sessions, cluster state). Coordination of distributed systems leads to boiler plate patterns, and using Spring Cloud developers can quickly stand up services and applications that implement those patterns. They will work well in any distributed environment, including the developer’s own laptop, bare metal data centres, and managed platforms such as Cloud Foundry.</p>
</div>
<p><a href="http://projects.spring.io/spring-cloud/" target="_blank" rel="noopener">Spring Cloud</a>是一个基于Spring Boot实现的云应用开发工具，它为基于JVM的云应用开发中的配置管理、服务发现、断路器、智能路由、微代理、控制总线、全局锁、决策竞选、分布式会话和集群状态管理等操作提供了一种简单的开发方式。</p>
<p>Spring Cloud包含了多个子项目（针对分布式系统中涉及的多个不同开源产品），比如：<a href="http://cloud.spring.io/spring-cloud-config" target="_blank" rel="noopener">Spring Cloud Config</a>、<a href="http://cloud.spring.io/spring-cloud-netflix" target="_blank" rel="noopener">Spring Cloud Netflix</a>、<a href="http://cloud.spring.io/spring-cloud-bus" target="_blank" rel="noopener">Spring Cloud Bus</a> 、<a href="http://cloud.spring.io/spring-cloud-cloudfoundry" target="_blank" rel="noopener">Spring Cloud CloudFoundry</a>、<a href="http://cloud.spring.io/spring-cloud-stream" target="_blank" rel="noopener">Spring Cloud Stream</a>、<a href="http://cloud.spring.io/spring-cloud-security" target="_blank" rel="noopener">Spring Cloud Security</a>、<a href="http://cloud.spring.io/spring-cloud-task" target="_blank" rel="noopener">Spring Cloud Task</a>、<a href="http://cloud.spring.io/spring-cloud-zookeeper" target="_blank" rel="noopener">Spring Cloud Zookeeper</a>、<a href="http://cloud.spring.io/spring-cloud-consul" target="_blank" rel="noopener">Spring Cloud Consul</a>、<a href="https://github.com/spring-cloud/spring-cloud-cli" target="_blank" rel="noopener">Spring Cloud CLI</a>等项目。</p>
<p>Spring Cloud 所包含项目的一个大概结构如下：</p>
<img src="/2017/03/29/Spring-Cloud-系列教程(1)%20-%20简介/Spring-Cloud.png" title="Spring Cloud Structure">

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.lisanlai.cn/2017/03/27/Error-Cannot-find-module-hexo-util/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李三来">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sam's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/03/27/Error-Cannot-find-module-hexo-util/" itemprop="url">
                  Error: Cannot find module 'hexo-util'
                </a>
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-27T16:25:03+08:00">
                2017-03-27
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Hexo/" itemprop="url" rel="index">
                    <span itemprop="name">Hexo</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/03/27/Error-Cannot-find-module-hexo-util/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/03/27/Error-Cannot-find-module-hexo-util/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>升级NexT主题以后，执行<code>hexo clean</code>，出错：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">✗ hexo clean         </span><br><span class="line">ERROR Script load failed: themes/next/scripts/tags/exturl.js</span><br><span class="line">Error: Cannot find module 'hexo-util'</span><br><span class="line">    at Function.Module._resolveFilename (module.js:325:15)</span><br><span class="line">    at Function.Module._load (module.js:276:25)</span><br><span class="line">    at Module.require (module.js:353:17)</span><br><span class="line">    at require (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/lib/hexo/index.js:213:21)</span><br><span class="line">    at /Users/lisanlai/lisanlai.github.io/themes/next/scripts/tags/exturl.js:8:12</span><br><span class="line">    at /Users/lisanlai/lisanlai.github.io/node_modules/hexo/lib/hexo/index.js:229:12</span><br><span class="line">    at tryCatcher (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/util.js:16:23)</span><br><span class="line">    at Promise._settlePromiseFromHandler (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:502:31)</span><br><span class="line">    at Promise._settlePromise (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:559:18)</span><br><span class="line">    at Promise._settlePromise0 (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:604:10)</span><br><span class="line">    at Promise._settlePromises (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:683:18)</span><br><span class="line">    at Promise._fulfill (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:628:18)</span><br><span class="line">    at Promise._resolveCallback (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:423:57)</span><br><span class="line">    at Promise._settlePromiseFromHandler (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:514:17)</span><br><span class="line">    at Promise._settlePromise (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:559:18)</span><br><span class="line">    at Promise._settlePromise0 (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:604:10)</span><br><span class="line">    at Promise._settlePromises (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:683:18)</span><br><span class="line">    at Promise._fulfill (/Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/promise.js:628:18)</span><br><span class="line">    at /Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/bluebird/js/release/nodeback.js:42:21</span><br><span class="line">    at /Users/lisanlai/lisanlai.github.io/node_modules/hexo/node_modules/hexo-fs/node_modules/graceful-fs/graceful-fs.js:78:16</span><br><span class="line">    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)</span><br><span class="line">INFO  Deleted database.</span><br></pre></td></tr></table></figure>
<p><strong>解决办法：重新安装hexo-util模块 </strong></p>
<p><code>npm install -- save-dev hexo-util</code></p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.lisanlai.cn/2017/03/26/Jira-rest-api-使用经验/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李三来">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sam's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/03/26/Jira-rest-api-使用经验/" itemprop="url">
                  Jira rest api 使用经验
                </a>
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-26T22:46:49+08:00">
                2017-03-26
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Development/" itemprop="url" rel="index">
                    <span itemprop="name">Development</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017/03/26/Jira-rest-api-使用经验/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2017/03/26/Jira-rest-api-使用经验/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h2 id="1-JIRA-REST-API-可以做什么？"><a href="#1-JIRA-REST-API-可以做什么？" class="headerlink" title="1. JIRA REST API 可以做什么？"></a>1. JIRA REST API 可以做什么？</h2><div class="note "><p>The Atlassian REST APIs provide a standard interface for interacting with JIRA and our other applications. </p>
<p>REST APIs provide access to resources (data entities) via URI paths. To use a REST API, your application will make an HTTP request and parse the response. Your methods will be the standard HTTP methods like GET, PUT, POST and DELETE. REST APIs operate over HTTP(s) making it easy to use with any programming language or framework. The input and output format for the JIRA REST APIs is <a href="http://www.json.org/" target="_blank" rel="noopener">JSON</a>.</p>
</div>
<p>我们可以通过REST API去访问收保护的资源，例如增、删、改、查ISSUES 。。。。。</p>
<p>支持标准的HTTP method，例如 GET, PUT, POST , DELETE</p>
<p>所有的API的input 和 output 都是 JSON 格式。</p>
<div class="note primary"><p>Rest API Reference ： <a href="https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis" target="_blank" rel="noopener">https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis</a></p>
</div>
<div class="note info"><p>REST URI 结构 ： <a href="http://host:port/context/rest/api-name/api-version/resource-name" target="_blank" rel="noopener">http://host:port/context/rest/api-name/api-version/resource-name</a></p>
</div>
<div class="note success"><p>资源列表 ： <a href="https://developer.atlassian.com/static/rest/jira/6.1.html" target="_blank" rel="noopener">https://developer.atlassian.com/static/rest/jira/6.1.html</a></p>
</div>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2017/03/26/Jira-rest-api-使用经验/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.lisanlai.cn/2016/12/14/Spring-Boot-Mybatis-多数据源配置/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李三来">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sam's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/12/14/Spring-Boot-Mybatis-多数据源配置/" itemprop="url">
                  Spring-Boot Mybatis 多数据源配置
                </a>
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-12-14T17:32:36+08:00">
                2016-12-14
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/SpringBoot/" itemprop="url" rel="index">
                    <span itemprop="name">SpringBoot</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2016/12/14/Spring-Boot-Mybatis-多数据源配置/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/12/14/Spring-Boot-Mybatis-多数据源配置/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <ol>
<li><p>这篇文章涉及到的类和配置文件列表：</p>
<ul>
<li>pom.xml</li>
<li>application.properties</li>
<li>MybatisProperties.java</li>
<li>AbstractDatasourceConfig.java</li>
<li>ReadDatasourceConfig.java</li>
<li>PrimaryDatasourceConfig.java</li>
</ul>
</li>
</ol>
<ol start="2">
<li><p>添加依赖：pom.xml</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.zaxxer<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>HikariCP<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">version</span>&gt;</span>2.5.1<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.mybatis<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>mybatis<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">version</span>&gt;</span>3.4.1<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.mybatis<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>mybatis-spring<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.3.0<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-tx<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">version</span>&gt;</span>4.3.4.RELEASE<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2016/12/14/Spring-Boot-Mybatis-多数据源配置/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.lisanlai.cn/2016/11/30/spring-boot-starter-data-redis-乱码/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李三来">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sam's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/11/30/spring-boot-starter-data-redis-乱码/" itemprop="url">
                  spring-boot-starter-data-redis 乱码
                </a>
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-11-30T14:17:22+08:00">
                2016-11-30
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Development/" itemprop="url" rel="index">
                    <span itemprop="name">Development</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2016/11/30/spring-boot-starter-data-redis-乱码/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/11/30/spring-boot-starter-data-redis-乱码/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <ol>
<li><p>RedisTemplate源码</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">RedisTemplate</span>&lt;<span class="title">K</span>, <span class="title">V</span>&gt; <span class="keyword">extends</span> <span class="title">RedisAccessor</span> <span class="keyword">implements</span> <span class="title">RedisOperations</span>&lt;<span class="title">K</span>, <span class="title">V</span>&gt;, <span class="title">BeanClassLoaderAware</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">boolean</span> enableTransactionSupport = <span class="keyword">false</span>;</span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">boolean</span> exposeConnection = <span class="keyword">false</span>;</span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">boolean</span> initialized = <span class="keyword">false</span>;</span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">boolean</span> enableDefaultSerializer = <span class="keyword">true</span>;</span><br><span class="line">	<span class="keyword">private</span> RedisSerializer&lt;?&gt; defaultSerializer;</span><br><span class="line">	<span class="keyword">private</span> ClassLoader classLoader;</span><br><span class="line">  </span><br><span class="line">	<span class="keyword">private</span> RedisSerializer keySerializer = <span class="keyword">null</span>;</span><br><span class="line">	<span class="keyword">private</span> RedisSerializer valueSerializer = <span class="keyword">null</span>;</span><br><span class="line">	<span class="keyword">private</span> RedisSerializer hashKeySerializer = <span class="keyword">null</span>;</span><br><span class="line">	<span class="keyword">private</span> RedisSerializer hashValueSerializer = <span class="keyword">null</span>;</span><br><span class="line">	<span class="keyword">private</span> RedisSerializer&lt;String&gt; stringSerializer = <span class="keyword">new</span> StringRedisSerializer();</span><br><span class="line">   </span><br><span class="line">  	....</span><br><span class="line">    <span class="comment">//spring-boot-starter-data-redis 默认情况下使用的是JdkSerializationRedisSerializer</span></span><br><span class="line">    <span class="comment">//这个地方是导致redis key乱码的根本原因</span></span><br><span class="line">    <span class="comment">//需要做的就是替换一下keySerializer 和 hashKeySerializer</span></span><br><span class="line">    <span class="keyword">if</span> (defaultSerializer == <span class="keyword">null</span>) &#123;</span><br><span class="line">		defaultSerializer = <span class="keyword">new</span> JdkSerializationRedisSerializer(</span><br><span class="line">			classLoader != <span class="keyword">null</span> ? classLoader : <span class="keyword">this</span>.getClass().getClassLoader());</span><br><span class="line">	&#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">if</span> (enableDefaultSerializer) &#123;</span><br><span class="line"></span><br><span class="line">			<span class="keyword">if</span> (keySerializer == <span class="keyword">null</span>) &#123;</span><br><span class="line">				keySerializer = defaultSerializer;</span><br><span class="line">				defaultUsed = <span class="keyword">true</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">if</span> (valueSerializer == <span class="keyword">null</span>) &#123;</span><br><span class="line">				valueSerializer = defaultSerializer;</span><br><span class="line">				defaultUsed = <span class="keyword">true</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">if</span> (hashKeySerializer == <span class="keyword">null</span>) &#123;</span><br><span class="line">				hashKeySerializer = defaultSerializer;</span><br><span class="line">				defaultUsed = <span class="keyword">true</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">if</span> (hashValueSerializer == <span class="keyword">null</span>) &#123;</span><br><span class="line">				hashValueSerializer = defaultSerializer;</span><br><span class="line">				defaultUsed = <span class="keyword">true</span>;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>重新申明RedisTemplate并设置keySerializer 和 hashKeySerializer</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Configuration</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">RedisConfiguration</span> </span>&#123;</span><br><span class="line">    <span class="meta">@Bean</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> RedisTemplate&lt;Object, Object&gt; <span class="title">redisTemplate</span><span class="params">(RedisConnectionFactory redisConnectionFactory)</span></span></span><br><span class="line"><span class="function">            <span class="keyword">throws</span> UnknownHostException </span>&#123;</span><br><span class="line">        RedisTemplate&lt;Object, Object&gt; template = <span class="keyword">new</span> RedisTemplate&lt;Object, Object&gt;();</span><br><span class="line">        template.setKeySerializer(<span class="keyword">new</span> StringRedisSerializer());</span><br><span class="line">        template.setHashKeySerializer(<span class="keyword">new</span> StringRedisSerializer());</span><br><span class="line">        template.setConnectionFactory(redisConnectionFactory);</span><br><span class="line">        <span class="keyword">return</span> template;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>​</p>
</li>
</ol>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.lisanlai.cn/2016/11/23/从源码编译安装nginx/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李三来">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sam's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/11/23/从源码编译安装nginx/" itemprop="url">
                  从源码编译安装nginx
                </a>
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-11-23T16:56:23+08:00">
                2016-11-23
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Development/" itemprop="url" rel="index">
                    <span itemprop="name">Development</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2016/11/23/从源码编译安装nginx/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/11/23/从源码编译安装nginx/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <ol>
<li><p>参考文档： <a href="http://nginx.org/en/docs/configure.html" target="_blank" rel="noopener">参考文档</a></p>
</li>
<li><p>下载nginx源码：<a href="http://nginx.org/download/" target="_blank" rel="noopener">download</a> </p>
</li>
<li><p>预先下载所需模块：<a href="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/" target="_blank" rel="noopener">pcre</a>     <a href="http://labs.frickle.com/nginx_ngx_cache_purge/" target="_blank" rel="noopener">nginx_ngx_cache_purge</a>    <a href="http://zlib.net/" target="_blank" rel="noopener">zlib</a></p>
</li>
<li><p>安装ssl模块：<code>yum -y install openssl openssl-devel</code></p>
</li>
<li><p>安装gcc编译器：<code>yum install -y gcc gcc-c++</code></p>
</li>
<li><p>目录结构如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">[devadmin_sam@hzserver nginx]$ ll</span><br><span class="line">总用量 24</span><br><span class="line">drwxr-xr-x  9 devadmin_sam dev  4096 11月 23 13:12 nginx-1.10.2</span><br><span class="line">drwxr-xr-x  3 devadmin_sam dev  4096 12月 24 2014 ngx_cache_purge-2.3</span><br><span class="line">drwxr-xr-x  9 devadmin_sam dev 12288 11月 23 13:14 pcre-8.39</span><br><span class="line">drwxr-xr-x 14 devadmin_sam dev  4096 11月 23 13:14 zlib-1.2.8</span><br></pre></td></tr></table></figure>
</li>
<li><p>编译参数：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">./configure\</span><br><span class="line">--prefix=/etc/nginx\</span><br><span class="line">--sbin-path=/usr/sbin/nginx\</span><br><span class="line">--conf-path=/etc/nginx/nginx.conf\</span><br><span class="line">--error-log-path=/var/log/nginx/error.log\</span><br><span class="line">--http-log-path=/var/log/nginx/access.log\</span><br><span class="line">--pid-path=/var/run/nginx.pid\</span><br><span class="line">--lock-path=/var/run/nginx.lock\</span><br><span class="line">--http-client-body-temp-path=/var/cache/nginx/client_temp\</span><br><span class="line">--http-proxy-temp-path=/var/cache/nginx/proxy_temp\</span><br><span class="line">--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp\</span><br><span class="line">--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp\</span><br><span class="line">--http-scgi-temp-path=/var/cache/nginx/scgi_temp\</span><br><span class="line">--user=nginx\</span><br><span class="line">--group=nginx\</span><br><span class="line">--with-http_ssl_module\</span><br><span class="line">--with-http_realip_module\</span><br><span class="line">--with-http_addition_module\</span><br><span class="line">--with-http_sub_module\</span><br><span class="line">--with-http_dav_module\</span><br><span class="line">--with-http_flv_module\</span><br><span class="line">--with-http_mp4_module\</span><br><span class="line">--with-http_gunzip_module\</span><br><span class="line">--with-http_gzip_static_module\</span><br><span class="line">--with-http_random_index_module\</span><br><span class="line">--with-http_secure_link_module\</span><br><span class="line">--with-http_stub_status_module\</span><br><span class="line">--with-http_auth_request_module\</span><br><span class="line">--with-threads\</span><br><span class="line">--with-stream\</span><br><span class="line">--with-stream_ssl_module\</span><br><span class="line">--with-http_slice_module\</span><br><span class="line">--with-mail\</span><br><span class="line">--with-mail_ssl_module\</span><br><span class="line">--with-file-aio\</span><br><span class="line">--with-http_v2_module\</span><br><span class="line">--with-ipv6\</span><br><span class="line">--with-pcre=../pcre-8.39\</span><br><span class="line">--with-zlib=../zlib-1.2.8\</span><br><span class="line">--add-module=../ngx_cache_purge-2.3</span><br></pre></td></tr></table></figure>
</li>
<li><p><code>make &amp;&amp; make install</code></p>
</li>
</ol>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.lisanlai.cn/2016/07/27/Java进程占用CPU过高排查方法/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李三来">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sam's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/07/27/Java进程占用CPU过高排查方法/" itemprop="url">
                  Java进程占用CPU过高排查方法
                </a>
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-07-27T10:06:05+08:00">
                2016-07-27
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Development/" itemprop="url" rel="index">
                    <span itemprop="name">Development</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2016/07/27/Java进程占用CPU过高排查方法/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/07/27/Java进程占用CPU过高排查方法/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <h2 id="1-利用TOP命令查看，发现Java进程持续占高CPU"><a href="#1-利用TOP命令查看，发现Java进程持续占高CPU" class="headerlink" title="1.利用TOP命令查看，发现Java进程持续占高CPU"></a>1.利用TOP命令查看，发现Java进程持续占高CPU</h2><pre><code>PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                  
4233 root      20   0 6667m 2.3g 8312 S 264.1 30.4  79979:06 java
</code></pre><h2 id="2-利用TOP-H找到对应进程下面线程的耗CPU情况"><a href="#2-利用TOP-H找到对应进程下面线程的耗CPU情况" class="headerlink" title="2.利用TOP -H找到对应进程下面线程的耗CPU情况"></a>2.利用TOP -H找到对应进程下面线程的耗CPU情况</h2><pre><code># top -H -p 4233
PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                  
 7041 root      20   0 6667m 2.3g 8312 S 20.1 30.4   5524:52 java                                     
 7048 root      20   0 6667m 2.3g 8312 S 18.8 30.4   5098:27 java                                     
 9625 root      20   0 6667m 2.3g 8312 S 18.5 30.4   7205:30 java                                     
10111 root      20   0 6667m 2.3g 8312 S 17.8 30.4   6008:08 java                                     
10254 root      20   0 6667m 2.3g 8312 S 17.8 30.4   6001:12 java                                     
10923 root      20   0 6667m 2.3g 8312 S 17.5 30.4   5999:17 java                                     
10033 root      20   0 6667m 2.3g 8312 S 17.1 30.4   6004:10 java                                     
 4353 root      20   0 6667m 2.3g 8312 S 16.8 30.4   7209:04 java                                     
 9685 root      20   0 6667m 2.3g 8312 S 16.8 30.4   6002:45 java                                     
 7042 root      20   0 6667m 2.3g 8312 S 16.5 30.4   7193:56 java                                     
 9910 root      20   0 6667m 2.3g 8312 S 16.5 30.4   6010:04 java                                     
10893 root      20   0 6667m 2.3g 8312 S 16.5 30.4   7195:46 java                                     
 4235 root      20   0 6667m 2.3g 8312 S 15.5 30.4 815:26.39 java                                          4238 root      20   0 6667m 2.3g 8312 R 12.9 30.4 815:54.11 java                                     
 4236 root      20   0 6667m 2.3g 8312 S 12.5 30.4 811:10.16 java                                     
 4237 root      20   0 6667m 2.3g 8312 S  9.6 30.4 814:50.57 java                                     
 4239 root      20   0 6667m 2.3g 8312 S  2.0 30.4 752:01.99 java                                          4294 root      20   0 6667m 2.3g 8312 S  0.7 30.4  56:16.83 java                                     
 4280 root      20   0 6667m 2.3g 8312 S  0.3 30.4  68:25.58 java                                     
 4233 root      20   0 6667m 2.3g 8312 S  0.0 30.4   0:00.00 java                                     
 4234 root      20   0 6667m 2.3g 8312 S  0.0 30.4   0:07.16 java                                     
 4240 root      20   0 6667m 2.3g 8312 S  0.0 30.4   0:10.14 java                                     
 4241 root      20   0 6667m 2.3g 8312 S  0.0 30.4   0:08.93 java                                     
 4242 root      20   0 6667m 2.3g 8312 S  0.0 30.4   0:00.00 java                                     
 4243 root      20   0 6667m 2.3g 8312 S  0.0 30.4   0:52.14 java                                     
 4244 root      20   0 6667m 2.3g 8312 S  0.0 30.4   0:47.82 java                                          4245 root      20   0 6667m 2.3g 8312 S  0.0 30.4   0:00.00 java                                     
 4246 root      20   0 6667m 2.3g 8312 S  0.0 30.4  19:30.64 java                                     
 4249 root      20   0 6667m 2.3g 8312 S  0.0 30.4   0:03.20 java 
</code></pre>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2016/07/27/Java进程占用CPU过高排查方法/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://blog.lisanlai.cn/2016/04/29/文件提取利器-Apache-Tika/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="李三来">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sam's Blog">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2016/04/29/文件提取利器-Apache-Tika/" itemprop="url">
                  文件提取利器-Apache Tika
                </a>
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-04-29T21:13:18+08:00">
                2016-04-29
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Development/" itemprop="url" rel="index">
                    <span itemprop="name">Development</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2016/04/29/文件提取利器-Apache-Tika/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/04/29/文件提取利器-Apache-Tika/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          <blockquote><p>Description: The Apache Tika™ toolkit detects and extracts metadata and text from over a thousand different file types (such as PPT, XLS, and PDF).<br>功能描述：Apache Tika 可以发现和提取各种各样类型文件的元数据（meatadata）和文件内容，例如:PPT，XLS 和PDF等等。</p>
<footer><strong>@官网</strong><cite><a href="https://tika.apache.org/" target="_blank" rel="noopener">tika.apache.org</a></cite></footer></blockquote>
<h2 id="Using-Tika-as-a-Maven-dependency"><a href="#Using-Tika-as-a-Maven-dependency" class="headerlink" title="Using Tika as a Maven dependency"></a>Using Tika as a Maven dependency</h2><pre><code>&lt;dependency&gt;
    &lt;groupId&gt;org.apache.tika&lt;/groupId&gt;
    &lt;artifactId&gt;tika-core&lt;/artifactId&gt;
    &lt;version&gt;1.13&lt;/version&gt;
  &lt;/dependency&gt;
</code></pre><blockquote>
<p>If you want to use Tika to parse documents (instead of simply detecting document types, etc.), you’ll want to depend on tika-parsers instead:</p>
</blockquote>
<pre><code>&lt;dependency&gt;
    &lt;groupId&gt;org.apache.tika&lt;/groupId&gt;
    &lt;artifactId&gt;tika-parsers&lt;/artifactId&gt;
    &lt;version&gt;1.13&lt;/version&gt;
  &lt;/dependency&gt;
</code></pre>
          <!--noindex-->
          <div class="post-button text-center">
            <a class="btn" href="/2016/04/29/文件提取利器-Apache-Tika/#more" rel="contents">
              阅读全文 &raquo;
            </a>
          </div>
          <!--/noindex-->
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
  </section>

  
  <nav class="pagination">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel sidebar-panel-active">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.png"
               alt="李三来" />
          <p class="site-author-name" itemprop="name">李三来</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
           
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">14</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">4</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">20</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/lisanlai" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/SanlaiLi" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-block">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://zoom.us" title="zoom" target="_blank">zoom</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">李三来</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  






  
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.1.3/jquery.min.js"></script>

  
  <script type="text/javascript" src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>

  
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery_lazyload/1.9.7/jquery.lazyload.min.js"></script>

  
  <script type="text/javascript" src="https://cdn.bootcss.com/velocity/1.2.1/velocity.min.js"></script>

  
  <script type="text/javascript" src="https://cdn.bootcss.com/velocity/1.2.1/velocity.ui.min.js"></script>

  
  <script type="text/javascript" src="https://cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.pack.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  

  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"lisanlai"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
      
      <script src="https://cdn.bootcss.com/UAParser.js/0.7.9/ua-parser.min.js"></script>
      <script src="/js/src/hook-duoshuo.js?v=5.1.0"></script>
    
    
    <script src="https://cdn.bootcss.com/UAParser.js/0.7.9/ua-parser.min.js"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  
















  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>




  
  
  
  <link rel="stylesheet" href="/lib/algolia-instant-search/instantsearch.min.css">

  
  
  <script src="/lib/algolia-instant-search/instantsearch.min.js"></script>
  

  <script src="/js/src/algolia-search.js?v=5.1.0"></script>



  

  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  

  

</body>
</html>
